var username = null;
var userNameMsg=null;
var subBtn=null;
$(function() {
    username = $("#userName");
    userNameMsg=$("#userNameMsg");
    subBtn=$("#subBtn");
    username.on("blur", function () {
        $.ajax({
            type: "POST",
            url:"/ssmbuild/getUserByName",
            data: { userName: username.val()},
            success: function (data) {
                if (data.toString()=== "ok") {
                    userNameMsg.css("color","green");
                    userNameMsg.html("√");
                } else if (data.toString() === "false") {
                    userNameMsg.css("color","red");
                    userNameMsg.html("用户名已被使用");
                    subBtn.attr('disabled','true');
                }else if (data.toString() === "NULL") {
                    userNameMsg.css("color","red");
                    userNameMsg.html("用户名不可为空");
                    subBtn.attr('disabled','true');
                }
            },
            error: function () {
                userNameMsg.css("color","red")
                userNameMsg.html("× 请求出错，快叫码农去改代码");
                subBtn.attr('disabled','true');
            }
        });
    });
});